package com.example.day2.test;

import java.util.ArrayList;

class Solution {
    public static int maxRepeating(String sequence, String word) {
        if (sequence.equals("")){
            if (word.equals("")){
                return 0;
            }
        }
        ArrayList<String> list = new ArrayList<>();
        int count=0;
        for (int i = 0; i < sequence.length()-1; i++) {
            String substring = sequence.substring(i);
            System.out.println(substring);
            list.add(substring);
        }
        for (String s : list) {
            if (s.indexOf(word)==0){
                count++;
            }
        }
        if (count==0){
            count=-1;
        }
        return count;
    }

    public static int maxRepeating2(String sequence, String word) {
        byte[] bytes = sequence.getBytes();
        for (byte aByte : bytes) {
            System.out.println((char) aByte);
        }
        return 0;
    }

    public static void main(String[] args) {
        String sequence="ababc";
        String word = "ab";
        int i = Solution.maxRepeating(sequence, word);
//        int ii = Solution.maxRepeating2(sequence, word);
        System.out.println(i);
    }
}